package controller;

import java.awt.event.KeyEvent;

import csel.controller.enums.ActionEnum;
import csel.controller.events.KeyPress;
import csel.controller.bindings.KeyBindings;
import csel.controller.decoders.EventDecoder;
import csel.controller.dispatchers.Dispatcher;
import csel.controller.decoders.KeyEventDecoder;
import csel.model.GameCommand;
import csel.model.Invoker;

public class TestThatEventSTATEMACHINEShitSon
{
	public static void main(String[] ags) throws InterruptedException
	{
		Dispatcher disp = new Dispatcher(new Thing());
		disp.startDispatcher();
		
		EventDecoder<KeyPress> decoder = new KeyEventDecoder( null, disp );
		Thread coolThread = new Thread( decoder );
		coolThread.start();
		
		
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_E) ); // goes to equip
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_S) ); // goes to skills
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_I) ); // goes to inventory
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to inv. equip
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to inv. dropable
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to drop equipable
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to gimp
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // back to inventory
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_S) ); // goes to skills
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to project skills
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to skills upgrade
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_EQUALS) ); // goes to skills again
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_TAB) ); // stays in same state
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_TAB) ); // stays in same state
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_TAB) ); // stays in same state
		decoder.registerEvent( new EventThinger(null, null,KeyEvent.VK_TAB) ); // stays in same state
		
		
		Thread.sleep( 1000 );
		coolThread.interrupt();
		disp.stopDispatcher();
	}
	
	private static class Thing implements Invoker
	{
		public void accept(GameCommand gc)
		{
			gc.execute();
		}
	}
	
	private static class EventThinger extends KeyPress
	{
		Integer k;
		KeyBindings kb = KeyBindings.getInstance();
		
		public EventThinger(KeyEvent event, KeyBindings keyBindings, Integer k)
		{
			super(event, keyBindings);
			this.k=k;
			// TODO Auto-generated constructor stub
		}
		public ActionEnum getActionEnum()
		{
			return kb.getEnum(k);
		}
	}
}
